package jp.ne.hatena.d.digitalsoul.warikan.actions

import java.io._
import java.util._

import jp.ne.hatena.d.digitalsoul.warikan.contexts._
import jp.ne.hatena.d.digitalsoul.warikan.pages.forms._
import jp.ne.hatena.d.digitalsoul.warikan.pages.items._
import jp.ne.hatena.d.digitalsoul.warikan.repositories._

class SlopeDetailAction extends Serializable {
	
	def createRoleValues:List[String] = {
		val roleValues = new ArrayList[String]
		RoleRepository.forAll.foreach { role => 
			roleValues.add(role.name)
		}
		roleValues
	}
	
	
	def executePreparation(mainFormModel:SlopeDetailMainForm, weightListItems:List[WeightListItem]) = {
		
		val preparation:Preparation = new Preparation
		preparation.setup(mainFormModel.slopeName)
			
		for(val i <- 0 until weightListItems.size) {
			val weightListItem = weightListItems.get(i)
			preparation.addMapping(weightListItem.role, weightListItem.weight.toInt)
		}
			
		preparation.commit
		
	}

}